package main
import(
	"fmt"
)
func main(){
	var slice []float64 = make([]float64,5,10)
	slice[1] = 10
	slice[3] = 20
	fmt.Println("slice.size=",len(slice))
	fmt.Println("slice.cap=",cap(slice))
	fmt.Printf("sllce.add=%p\n",&slice)
	fmt.Println("sllce[0].add=",&slice[0])
	fmt.Println("sllce[1].add=",&slice[1])
	fmt.Println("sllce[2].add=",&slice[2])


	// 方式3 定义切片
	fmt.Println("定义切片 3")
	var strSlice []string = []string{"tom","jack","mary"}

	fmt.Println("strSlice.size=",len(strSlice))
	fmt.Println("slistrSlicece.cap=",cap(strSlice))
	fmt.Println("strSlice=",strSlice)

	for i,v := range strSlice{
		fmt.Printf("i=%v v=%v\n",i,v)
	}

	slice2 := strSlice[1:2] // slice2 jack
	fmt.Println("slice2[0]=",slice2[0])
	slice2[0] = "cat" // strSlice[1] ,slice2[0] = "cat"
	fmt.Println("slice2[0]=",slice2[0])
	fmt.Println("strSlice[1]=",strSlice[1])

	// append动态追加
	var slice3 []int = []int{100,200,300}
	slice3 = append(slice3,400,500,600,900)
	slice3 = append(slice3,700)
	fmt.Println("slice3=",slice3)

	// 通过append 将切片最佳给slice3 
	slice3 = append(slice3,slice3...)
	fmt.Println("slice3=",slice3)


}